import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mall/constant/app_colors.dart';
import 'package:mall/modules/sc/user_sc.dart';
import 'package:mall/ui/page/mine/user_info/widgets/chang_name_widget.dart';
import 'package:mall/ui/widgets/app_base_widgets/app_form_item_widget.dart';
import 'package:mall/ui/widgets/divider_line.dart';
import 'package:mall/utils/image_component/image_component.dart';

class UserInfoPage extends StatefulWidget {
  const UserInfoPage({super.key});

  @override
  State<UserInfoPage> createState() => _UserInfoPageState();
}

class _UserInfoPageState extends State<UserInfoPage> {
  final sc_user = Get.put(UserSc());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('个人信息'),
      ),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(15),
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.only(left: 15),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(15),
              ),
              child: Column(
                children: [
                  Obx(() => AppFormItemWidget(
                        leftText: '头像',
                        rightWidget: ClipRRect(
                          borderRadius: BorderRadius.circular(13),
                          child: ImageComponent(
                            sc_user.data.value?.avatarUrl,
                            size: 26,
                          ),
                        ),
                        callback: () {},
                      )),
                  Obx(() => AppFormItemWidget(
                        leftText: '昵称',
                        rightText: sc_user.data.value?.nickName ?? "---",
                        callback: () {
                          Get.dialog(ChangNameWidget(
                            name: sc_user.data.value?.nickName,
                          ));
                        },
                      )),
                  DividerLineView(),
                  Obx(() => AppFormItemWidget(
                        leftText: '手机号',
                        rightText: sc_user.data.value?.mobile ?? "---",
                        callback: () {},
                      )),
                ],
              ),
            ),
            SizedBox(height: 10),
            Container(
              padding: EdgeInsets.only(left: 15),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(15),
              ),
              child: Column(
                children: [
                  Obx(() => AppFormItemWidget(
                        leftText: '性别',
                        rightText: sc_user.data.value?.nickName ?? "---",
                        callback: () {},
                      )),
                  DividerLineView(),
                  Obx(() => AppFormItemWidget(
                        leftText: '生日',
                        rightText: sc_user.data.value?.mobile ?? "---",
                        callback: () {},
                      )),
                  DividerLineView(),
                  AppFormItemWidget(
                    leftText: '修改登录密码',
                    callback: () {},
                  ),
                ],
              ),
            ),
            SizedBox(height: 10),

            //退出登录
            InkWell(
              child: Container(
                height: 50,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(15)),
                  color: AppColors.C_FFFFFF,
                ),
                alignment: Alignment.center,
                child: Text('退出登录', style: TextStyle(color: AppColors.C_666666, fontSize: 16)),
              ),
            )
          ],
        ),
      ),
    );
  }
}
